USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[Kaze]    Script Date: 04/24/2014 13:31:12 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Kaze]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[Kaze]
GO

USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[Kaze]    Script Date: 04/24/2014 13:31:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE FUNCTION [dbo].[Kaze]
(
	@SYUMOKUKUBUN int,
	@SUBSYUMOKUKUBUN int,
	@KIROKU VARCHAR(10),
	@EXTEND1 VARCHAR(10)
)
RETURNS  varchar(50)
AS
BEGIN
	DECLARE @return varchar(50)

	IF (@SYUMOKUKUBUN = 1) OR (@SUBSYUMOKUKUBUN = 1)
		IF @KIROKU = 'w'
			IF @EXTEND1 = ''
				SET @return = ''
			ELSE
				SET @return = '(' + @EXTEND1 + ')'
		ELSE 
			SET @return = @KIROKU + '<br/>' + @EXTEND1
	ELSE IF(@SYUMOKUKUBUN = 8) OR (@SUBSYUMOKUKUBUN = 8) OR (@SUBSYUMOKUKUBUN = 6)
		SET @return = @KIROKU + '<br/>' + @EXTEND1
	ELSE
		IF @KIROKU = 'w' OR @KIROKU = ''
			SET @return = ''
		ELSE 
			SET @return = @KIROKU	
	

	RETURN @return

END